import { IPSAppDELogicNode } from '../../app/dataentity/ipsapp-delogic-node';
import { IPSDELogicLink } from './ipsdelogic-link';
import { IPSDELogicNode } from './ipsdelogic-node';
import { IPSDELogicNodeParam } from './ipsdelogic-node-param';
import { IPSSysSFPlugin } from '../../res/ipssys-sfplugin';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDELogicNodeImpl extends PSModelObjectImpl implements IPSDELogicNode, IPSAppDELogicNode {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get height(): number {
    return this.M.height != null ? this.M.height : 0;
  }

  get leftPos(): number {
    return this.M.leftPos != null ? this.M.leftPos : 0;
  }

  get logicNodeType():
    | 'BEGIN'
    | 'DEACTION'
    | 'PREPAREPARAM'
    | 'RESETPARAM'
    | 'COPYPARAM'
    | 'BINDPARAM'
    | 'APPENDPARAM'
    | 'SORTPARAM'
    | 'RENEWPARAM'
    | 'FILTERPARAM'
    | 'FILTERPARAM2'
    | 'MERGEPARAM'
    | 'AGGREGATEPARAM'
    | 'LOOPSUBCALL'
    | 'RAWSQLCALL'
    | 'RAWSQLANDLOOPCALL'
    | 'RAWWEBCALL'
    | 'STARTWF'
    | 'CANCELWF'
    | 'THROWEXCEPTION'
    | 'SFPLUGIN'
    | 'RAWSFCODE'
    | 'SYSLOGIC'
    | 'SYSUTIL'
    | 'PREPAREJSPARAM'
    | 'VIEWCTRLINVOKE'
    | 'RAWJSCODE'
    | 'MSGBOX'
    | 'PFPLUGIN'
    | 'DEUIACTION'
    | 'MAINSTATE'
    | 'DEDATASET'
    | 'DENOTIFY'
    | 'DELOGIC'
    | 'COMMIT'
    | 'ROLLBACK'
    | 'DEBUGPARAM'
    | 'DEDATAQUERY'
    | 'DEPRINT'
    | 'DEREPORT'
    | 'DEDTSQUEUE'
    | 'DEDATASYNC'
    | 'DEDATAIMP'
    | 'DEDATAEXP'
    | 'DEDATAAUDIT'
    | 'SUBSYSSAMETHOD'
    | 'SYSDATASYNCAGENTOUT'
    | 'SYSDBTABLEACTION'
    | 'SYSBDTABLEACTION'
    | 'SYSSEARCHDOCACTION'
    | 'SYSBIREPORT'
    | 'END' {
    return this.M.logicNodeType;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdelogiclinks: IPSDELogicLink[] | null = null;

  getPSDELogicLinks(): IPSDELogicLink[] | null {
    if (this.psdelogiclinks == null) {
      this.psdelogiclinks = this.fillChildListModel(this.M.getPSDELogicLinks, 'dataentity.logic.IPSDELogicLink') as IPSDELogicLink[];
    }
    return this.psdelogiclinks;
  }

  get psDELogicLinks(): IPSDELogicLink[] | null {
    return this.getPSDELogicLinks();
  }

  findPSDELogicLink(objKey: any): IPSDELogicLink | null {
    return this.getPSModel5('dataentity.logic.IPSDELogicLink', this.getPSDELogicLinks(), objKey) as IPSDELogicLink;
  }

  protected psdelogicnodeparams: IPSDELogicNodeParam[] | null = null;

  getPSDELogicNodeParams(): IPSDELogicNodeParam[] | null {
    if (this.psdelogicnodeparams == null) {
      this.psdelogicnodeparams = this.fillChildListModel(this.M.getPSDELogicNodeParams, 'dataentity.logic.IPSDELogicNodeParam') as IPSDELogicNodeParam[];
    }
    return this.psdelogicnodeparams;
  }

  get psDELogicNodeParams(): IPSDELogicNodeParam[] | null {
    return this.getPSDELogicNodeParams();
  }

  findPSDELogicNodeParam(objKey: any): IPSDELogicNodeParam | null {
    return this.getPSModel5('dataentity.logic.IPSDELogicNodeParam', this.getPSDELogicNodeParams(), objKey) as IPSDELogicNodeParam;
  }

  protected pssyssfplugin: IPSSysSFPlugin | null = null;

  getPSSysSFPlugin(): IPSSysSFPlugin | null {
    if (this.pssyssfplugin != null) return this.pssyssfplugin;
    const value = this.M.getPSSysSFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyssfplugin = this.getPSModel4('res.IPSSysSFPlugin', value, 'getPSSysSFPlugin') as IPSSysSFPlugin;
    return this.pssyssfplugin;
  }

  get psSysSFPlugin(): IPSSysSFPlugin | null {
    return this.getPSSysSFPlugin();
  }

  getPSSysSFPluginMust(): IPSSysSFPlugin {
    const value = this.getPSSysSFPlugin();
    if (value == null) {
      throw new Error('未指定后台扩展插件');
    }
    return value;
  }

  get topPos(): number {
    return this.M.topPos != null ? this.M.topPos : 0;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get width(): number {
    return this.M.width != null ? this.M.width : 0;
  }

  get parallelOutput(): boolean {
    return this.M.parallelOutput != null ? this.M.parallelOutput : false;
  }

  get cls(): string {
    return 'PSDELogicNodeImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.dataentity.IPSAppDELogicNode' || cls == 'dataentity.logic.IPSDELogicNode') return true;
    return super.instanceof(cls);
  }
}
